<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con">
            <span>新建渠道客户</span><div class="move_title"></div><?php include "../public/sub.php";?></div>
    </div>
    <div class="main-container">
        <div class="block-generic">


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>客户名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6" style="z-index: 99;">
                        <label class="layui-form-label">所在地区</label>
                        <div class="layui-input-block" style="z-index: 1;">
                            <input type="text" name="address" id="address" placeholder="请选择" readonly clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">客户来源</label>
                        <div class="layui-input-block">
                            <div id="source"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">客户类型</label>
                        <div class="layui-input-block">
                            <div id="type"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系人</label>
                        <div class="layui-input-block">
                            <input type="text" name="contacts" id="contacts" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="contacts_tel" id="contacts_tel" placeholder="请输入"  clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系地址</label>
                        <div class="layui-input-block">
                            <input type="text" id="contacts_addr" name="contacts_addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">客户归属人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=belong&type=use','770px','490px');"></div>
                                <div class="tanxiannei" id="belong"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=belong&type=use','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="custodianid_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">客户状态</label>
                        <div class="layui-input-block">
                            <div id="state"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">客户说明</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <?php include '../public/upinfo.php'?>
        </div>


    </div>
</form>
<script>
    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入客户名称"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form;
        render_input_attr();


        facade.ajax({type: 'get', url: ask_bid_customer_add}).done(function(res){
            if (res.code === 2000) {
                tan_tags_init('#belong', res.data.belong_info);
                load_areas('address', res.data.address, 3);

                xmselect_dan('type', res.data.type, '');
                xmselect_dan('source', res.data.source, '');
                xmselect_dan('state', res.data.state, '');

                public_upload_file_load('upload_files');
                render_date();
                render_from();
                initParseMoney();
            }
        });

        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();

            data.field.belong = tan_tags_getvalue('#belong', 'user');

            if(!validRes){return false;}

            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);
            facade.ajax({url: ask_bid_customer_add, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });
</script>
</body>
</html>
